package it.giuseppefrattura.wwdefence;

import org.andengine.engine.camera.Camera;
import org.andengine.entity.modifier.MoveXModifier;
import org.andengine.entity.sprite.Sprite;

public class Soldier{	

	    public Sprite sprite;
	    public static Soldier instance;
	    Camera mCamera;
		private float x,y;

	    public Sprite getSprite(){
	    	return this.sprite;
	    }
	    
	    public Soldier(float px, float py) {
	    	instance=this;
	    	this.x=px;this.y=py;
	        sprite = new Sprite(px, py, MainActivity.getSharedInstance().mSol2, 
	        		MainActivity.getSharedInstance().getVertexBufferObjectManager());				        
	        mCamera = MainActivity.getSharedInstance().mCamera;
	    }
	    
	    public void shoot(float x, float y) {
	        GameScene scene = (GameScene) MainActivity.getSharedInstance().mCurrentScene;
	        Bullets b = (Bullets) BulletPool.sharedBulletPool().obtainPoolItem();
	        b.sprite.setPosition(x,y);//sprite.getX(), sprite.getY());
	        MoveXModifier mod = new MoveXModifier(1.5f, b.sprite.getX(), -b.sprite.getWidth());
	        b.sprite.setVisible(true);
	        b.sprite.detachSelf();
	        scene.attachChild(b.sprite);
	        scene.bulletList.add(b);
	        b.sprite.registerEntityModifier(mod);
	        scene.bulletCount++;
	    }
	    
		public float getX() {
			return x;
		}

		public void setX(float x) {
			this.x = x;
		}

		public float getY() {
			return y;
		}

		public void setY(float y) {
			this.y = y;
		}
	
}
